package com.ruoyi.project.monitor.job.task;

import com.ruoyi.project.beautyflower.repaymentPlan.domain.RepaymentPlan;
import com.ruoyi.project.beautyflower.repaymentPlan.mapper.RepaymentPlanMapper;
import com.ruoyi.project.tool.push.JPushUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{
    @Autowired(required = false)
    private RepaymentPlanMapper  repaymentPlanMapper;
    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    public  void selectRepaymentPlanListByDudate(){
        List<RepaymentPlan> repaymentPlanList=repaymentPlanMapper.selectRepaymentPlanListByDudate();
        for (RepaymentPlan repaymentPlan : repaymentPlanList) {
            String title = "尊敬的"+repaymentPlan.getMemberName()+"先生 /女士,您的借款第"+repaymentPlan.getInstallmentNo()+"期"+repaymentPlan.getDueDate()+"到还款日，请及时处理";
            Map<String, String> extra = new HashMap<>();
            extra.put("type", "1");
//            // 订单ID
            extra.put("id", repaymentPlan.getOrderNumber());
            JPushUtil.get().pushAlias(repaymentPlan.getUuid()+"_" +repaymentPlan.getMomberId(), title, extra);
        }
//        System.out.println("共有"+repaymentPlanList.size()+"条还款计划即将还款");
    }

}
